
package com.caration.shell.settings;

import android.net.wifi.WifiManager;

import com.caration.shell.cr3d.SharedData;

public final class WifiStateManager {
    private static final String SYNC = "sync";
    private static WifiStateManager sInstance;
    private int mWifiState;
    private IconTexture mIconTexture;

    // private RenderRunnable mRenderRunnable;

    public static WifiStateManager getInstance() {
        synchronized (SYNC) {
            if (sInstance == null)
                sInstance = new WifiStateManager();
        }
        return sInstance;
    }

    // static void a(ad ad1)
    // {
    // ad1.mRenderRunnable = null;
    // }

    public final void a(IconTexture iconTexture) {
        mIconTexture = iconTexture;
        mWifiState = ((WifiManager) SharedData.getContext().getSystemService("wifi")).getWifiState();
        setupIcon();
    }

    public final void setupIcon() {
        if (mIconTexture != null)
            switch (mWifiState) {
                case 0: // '\0'
                    mIconTexture.setupTexture(2);
                    break;

                case 1: // '\001'
                    mIconTexture.setupTexture(0);
                    break;

                case 2: // '\002'
                    mIconTexture.setupTexture(2);
                    break;

                case 3: // '\003'
                    mIconTexture.setupTexture(1);
                    break;

                case 4: // '\004'
                    mIconTexture.setupTexture(0);
                    break;
            }
    }

    // TODO: 更新 并刷新图标纹理
    public final void update() {
        // if(StaticShared.getContext() != null && com.censivn.C3DEngine.a.a() != null)
        // {
        // mWifiState =
        // ((WifiManager)StaticShared.getContext().getSystemService("wifi")).getWifiState();
        // if(mRenderRunnable != null)
        // {
        // com.censivn.C3DEngine.a.a().b(mRenderRunnable);
        // mRenderRunnable = null;
        // }
        // mRenderRunnable = new ae(this);
        // if(j.a().b())
        // mRenderRunnable.autoInvalidate = true;
        // com.censivn.C3DEngine.a.a().a(mRenderRunnable);
        // if(mIconTexture != null)
        // {
        // IconTexture _tmp = mIconTexture;
        // IconTexture.q();
        // }
        // }
    }
}
